

$(function (){
	queryLinkcydw(1,"成员单位","cydw");//成员单位
	queryLinkcydw(2,"省内信用单位","snxy");//省内信用
	queryLinkcydw(3,"省外信用单位","swxy");//省外信用

	
	//queryimglink(1,2,"#bottom dl",1);//二维码
	queryimglink(1,2,"#swxy",3);
	queryimglink(1,2,"#swxy",4);
	var htmlStr2=' <div id="friendlinks" class="warp100"><div class="warp1180 box1234"><div  id="cydw" style="float:left">'
		+' </div><div id="snxy" style="float:left"></div><div  id="swxy" style="float:left"></div>'
		+' </div></div>  <div id="bottom" class="warp1180"><dl><dt>版权所有：滨州市发展和改革委员会  '
		+'技术支持:上海三零卫士信息安全有限公司<br>鲁ICP备14019374号</dt>'
		 +'<dd class="line"> <img src="images/logo_bottom.png" width="156" height="49" /></dd>'
		 +'<dd>地址：山东省滨州市滨城区黄河五路385号<br> 电话：0543-3162871</dd></dl> </div> ';

	$("#bottomId").append(htmlStr2);
})

//初始化图片链接
function queryimglink(page,rows,idstr,linktype){
	$.ajax({
		  type: "post",
		  url: "../link/queryLink",
		  data: {
			  'isDel':'1',//前台显示
			  'imgTextType':'2',
			  'linkType':linktype,//所属类型 2惩戒系统 
			  'page':page,
			  'rows':rows
		  },
		  dataType: "json",
		  success: function(data){
				 var list = data.rows;
				 var str = '';
				
				 $.each(list, function(index, entity){
					 var nowDate = entity.createTime;
					 var now = new Date(nowDate);
					 var time= now.format("yyyy-MM-dd");
					 if(linktype=='3'||linktype=='4'){
						 str='<a href="'+entity.linkUrl+'" target="_blank" class="img"><img src=../images/uploadimg/'+entity.linkImg+' width="194" height="45" /></a>';
					 }else{
						 if(entity.orderId==1){//1为标题栏
							 if(linktype=='1'){
								 str+='<dt><a href="'+entity.linkUrl+'"><img src=../images/uploadimg/'+entity.linkImg+' width="640" height="81" /></a><BR />'+entity.linkName+'</dt>';
							 }else {
								 str+='<dt><a href="'+entity.linkUrl+'"><img src=../images/uploadimg/'+entity.linkImg+' width="640" height="81" /></a></dt>';
							 }
						 }else if(entity.orderId%2 ==0){//左侧
							 str+='<dd><a href="'+entity.linkUrl+'"><img src=../images/uploadimg/'+entity.linkImg+' width="316" height="85" /></a></dd>';
						 }else if(entity.orderId%2 !=0){//右侧
							 str+='<dd class="norightsp"><a href="'+entity.linkUrl+'"><img src=../images/uploadimg/'+entity.linkImg+' width="316" height="85" /></a></dd>';
						 }
					 }
				 })
				
				 $(idstr).append(str);//subject
		  }
	  })
}

//初始化 成员单位
function queryLinkcydw(linkType,name,divid){
	$.ajax({
		  type: "post",
		  url: "../link/queryLink",
		  data: {
			  'isDel':'1',//前台显示
			  'imgTextType':'1',//文字显示
			  'linkType':linkType//, // 1成员单位  2 省内信用 3省外信用
		  },
		  dataType: "json",
		  error:function(){
			  loadStats=='1';
			},
		  success: function(data){
				 var list = data.rows;
				 var cydw ="<select onchange='openurl(this)' size='1'><option value='' selected=''>"+name+"</option>";
				 $.each(list, function(index, entity){
							 cydw+="<option value='"+entity.linkUrl+"'>"+entity.linkName+"</option>";
				 })
				 cydw+="</select>";
				 
				 $("#"+divid).prepend(cydw);
				
		  }
	  })
}
//跳转至单位网站
function openurl(url){
	window.open(url.value); 
}
//时间格式化
Date.prototype.format = function(format){
	var o = {
	"M+" : this.getMonth()+1, //month
	"d+" : this.getDate(), //day
	"h+" : this.getHours(), //hour
	"m+" : this.getMinutes(), //minute
	"s+" : this.getSeconds(), //second
	"q+" : Math.floor((this.getMonth()+3)/3), //quarter
	"S" : this.getMilliseconds() //millisecond
	}

	if(/(y+)/.test(format)) {
	format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}

	for(var k in o) {
	if(new RegExp("("+ k +")").test(format)) {
	format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
	}
	}
	return format;
	}
